import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDPet {
	/**ID*/
	id,
	/**名称*/
	name,
	/**描述*/
	desc,
	/**模型/立绘*/
	model,
	/**进化1*/
	model_1,
	/**进化2*/
	model_2,
	/**宠物稀有度*/
	rare,
	/**宠物属性*/
	petType,
	/**宠物定位*/
	position,
	/**宠物定位名称*/
	positionName,
	/**升级属性*/
	baseMath,
	/**升星属性*/
	talentMath,
	/**觉醒属性*/
	wakeMath,
	/**基础觉醒id*/
	wakeBaseid,
	/**升星特殊消耗*/
	rankItem,
	/**分解返还道具数量*/
	backRankNum,
	/**进化消耗道具2*/
	rankItem2,
	/**进化消耗道具2数量*/
	rankItem2Num,
	/**分解返还经验道具id：global[10]*/
	backExpNum,
	/**普攻*/
	nomarlSkill,
	/**被动，最多配置2个*/
	passiveSkill,
	/**动画文件1*/
	animation_1,
	/**动画文件2*/
	animation_2,
	/**动画文件3*/
	animation_3,
	/**头像*/
	head,
	/**颜色1白2绿3蓝4紫5橙6红*/
	color,
	/**图标*/
	icon,
	/**图鉴分类*/
	handBookId,
	/**模型大小*/
	scale,

	/**枚举数量*/
	EnumCount
}



export class CDPet{
	/**ID*/
	public id: number;
	/**名称*/
	public name: number;
	/**描述*/
	public desc: number;
	/**模型/立绘*/
	public model: string;
	/**进化1*/
	public model_1: string;
	/**进化2*/
	public model_2: string;
	/**宠物稀有度*/
	public rare: number;
	/**宠物属性*/
	public petType: number;
	/**宠物定位*/
	public position: number;
	/**宠物定位名称*/
	public positionName: number;
	/**升级属性*/
	public baseMath: number;
	/**升星属性*/
	public talentMath: number;
	/**觉醒属性*/
	public wakeMath: number;
	/**基础觉醒id*/
	public wakeBaseid: number;
	/**升星特殊消耗*/
	public rankItem: number;
	/**分解返还道具数量*/
	public backRankNum: number;
	/**进化消耗道具2*/
	public rankItem2: number;
	/**进化消耗道具2数量*/
	public rankItem2Num: number;
	/**分解返还经验道具id：global[10]*/
	public backExpNum: number;
	/**普攻*/
	public nomarlSkill: number;
	/**被动，最多配置2个*/
	public passiveSkill: number[];
	/**动画文件1*/
	public animation_1: string;
	/**动画文件2*/
	public animation_2: string;
	/**动画文件3*/
	public animation_3: string;
	/**头像*/
	public head: string;
	/**颜色1白2绿3蓝4紫5橙6红*/
	public color: number;
	/**图标*/
	public icon: string;
	/**图鉴分类*/
	public handBookId: number;
	/**模型大小*/
	public scale: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDPet.id: return this.id;
			case E_CDPet.name: return this.name;
			case E_CDPet.desc: return this.desc;
			case E_CDPet.model: return this.model;
			case E_CDPet.model_1: return this.model_1;
			case E_CDPet.model_2: return this.model_2;
			case E_CDPet.rare: return this.rare;
			case E_CDPet.petType: return this.petType;
			case E_CDPet.position: return this.position;
			case E_CDPet.positionName: return this.positionName;
			case E_CDPet.baseMath: return this.baseMath;
			case E_CDPet.talentMath: return this.talentMath;
			case E_CDPet.wakeMath: return this.wakeMath;
			case E_CDPet.wakeBaseid: return this.wakeBaseid;
			case E_CDPet.rankItem: return this.rankItem;
			case E_CDPet.backRankNum: return this.backRankNum;
			case E_CDPet.rankItem2: return this.rankItem2;
			case E_CDPet.rankItem2Num: return this.rankItem2Num;
			case E_CDPet.backExpNum: return this.backExpNum;
			case E_CDPet.nomarlSkill: return this.nomarlSkill;
			case E_CDPet.passiveSkill: return this.passiveSkill;
			case E_CDPet.animation_1: return this.animation_1;
			case E_CDPet.animation_2: return this.animation_2;
			case E_CDPet.animation_3: return this.animation_3;
			case E_CDPet.head: return this.head;
			case E_CDPet.color: return this.color;
			case E_CDPet.icon: return this.icon;
			case E_CDPet.handBookId: return this.handBookId;
			case E_CDPet.scale: return this.scale;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDPet.id: this.id = v; break;
			case E_CDPet.name: this.name = v; break;
			case E_CDPet.desc: this.desc = v; break;
			case E_CDPet.model: this.model = v; break;
			case E_CDPet.model_1: this.model_1 = v; break;
			case E_CDPet.model_2: this.model_2 = v; break;
			case E_CDPet.rare: this.rare = v; break;
			case E_CDPet.petType: this.petType = v; break;
			case E_CDPet.position: this.position = v; break;
			case E_CDPet.positionName: this.positionName = v; break;
			case E_CDPet.baseMath: this.baseMath = v; break;
			case E_CDPet.talentMath: this.talentMath = v; break;
			case E_CDPet.wakeMath: this.wakeMath = v; break;
			case E_CDPet.wakeBaseid: this.wakeBaseid = v; break;
			case E_CDPet.rankItem: this.rankItem = v; break;
			case E_CDPet.backRankNum: this.backRankNum = v; break;
			case E_CDPet.rankItem2: this.rankItem2 = v; break;
			case E_CDPet.rankItem2Num: this.rankItem2Num = v; break;
			case E_CDPet.backExpNum: this.backExpNum = v; break;
			case E_CDPet.nomarlSkill: this.nomarlSkill = v; break;
			case E_CDPet.passiveSkill: this.passiveSkill = v; break;
			case E_CDPet.animation_1: this.animation_1 = v; break;
			case E_CDPet.animation_2: this.animation_2 = v; break;
			case E_CDPet.animation_3: this.animation_3 = v; break;
			case E_CDPet.head: this.head = v; break;
			case E_CDPet.color: this.color = v; break;
			case E_CDPet.icon: this.icon = v; break;
			case E_CDPet.handBookId: this.handBookId = v; break;
			case E_CDPet.scale: this.scale = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDPet> = new HashMap<number, CDPet>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDPet[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDPet();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].name = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].desc = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].model = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].model_1 = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].model_2 = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].rare = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].petType = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].position = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].positionName = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].baseMath = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].talentMath = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].wakeMath = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].wakeBaseid = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rankItem = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].backRankNum = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rankItem2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rankItem2Num = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].backExpNum = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].nomarlSkill = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].passiveSkill = [];
			const attrArray = list[i].passiveSkill;
			const arraySize = byte.readInt32();
			for (let j = 0; j < arraySize; j++) {
				attrArray[j] = byte.readInt32();
			}
		}
		for (i = 0; i < size; i++) {
			list[i].animation_1 = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].animation_2 = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].animation_3 = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].head = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].color = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].icon = byte.readString();
		}
		for (i = 0; i < size; i++) {
			list[i].handBookId = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].scale = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDPet{
		return this.datas ? this.datas.get(id) : null;
	}
}
